import { Base64 } from 'js-base64'

function toBase64(buffer: Array<number>): string {
  let binary = ''
  const bytes = new Uint8Array(buffer)
  const len = bytes.byteLength
  for (let i = 0; i < len; i += 1) {
    binary += String.fromCharCode(bytes[i])
  }

  return Base64.btoa(binary)
}

export { toBase64 }
